home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cppfos.arc / FOSSIL.CPP next >
C/C++ Source or Header  |  1991-05-21  |  41KB  |  1,829 lines

  1. // Module //
  2.  
  3. // Contents -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  4. //
  5. //    FOSSIL.CPP
  6. //
  7. //    Copyright (C) 1991 by J.R.Louvau
  8. //    All rights reserved.
  9. //
  10. // License
  11. //
  12. //    This source code is freely available, copyrighted material.
  13. //    You are free to incorporate it into other software you are developing
  14. //    in original or modified form. You may also distribute it in any way
  15. //    you see fit, provided you follow these guidelines:
  16. //    1) The contents of the header (".hpp") and source (".cpp") remain
  17. //       in their original form.
  18. //    2) You don't make a profit.
  19. //    3) Charging for a package you have developed which incorporates
  20. //       these routines in BINARY (.obj, .exe, etc.) is fine, but you may
  21. //       NOT include this SOURCE CODE in any for-profit package.
  22. //
  23. // Warranties, Liabilities, etc. ad nauseum
  24. //
  25. //    None! It works on my compiler, hardware, modem, etc. If it works
  26. //    for you, great... if not, well, that's why you got the source code -
  27. //    so that YOU could fix it ;-) You can't get blood from a turnip,
  28. //    and I'm a turnip. Help save the environment: starve a lawyer.
  29. //
  30. // Description
  31. //
  32. //    Implementation routines for class Fossil.
  33. //
  34. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  35.  
  36. // Interface Dependencies -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  37.  
  38. #include "fossil.hpp"
  39.  
  40. // End Interface Dependencies -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  41.  
  42. // Implementation Dependencies =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  43.  
  44. #include <dos.h>
  45. #include <string.h>
  46. #include <stdlib.h>
  47. #include <stdio.h>
  48.  
  49. // End Implementation Dependencies =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  50.  
  51. // Constructor //
  52.  
  53. FosIo::FosIo()
  54.  
  55. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  56. //
  57. // Paramaters
  58. //
  59. //    None
  60. //
  61. // Return Value
  62. //
  63. //    None
  64. //
  65. // Functional Description
  66. //
  67. //    Empty constructor
  68. //
  69. // Remarks
  70. //
  71. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  72. {
  73. }
  74. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  75.  
  76. // Destructor
  77.  
  78. FosIo::~FosIo()
  79.  
  80. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  81. //
  82. // Paramaters
  83. //
  84. //    None
  85. //
  86. // Return Value
  87. //
  88. //    None
  89. //
  90. // Functional Description
  91. //
  92. //    Empty destructor
  93. //
  94. // Remarks
  95. //
  96. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  97. {
  98. }
  99. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  100.  
  101. // Member Function //
  102.  
  103. unsigned int FosIo::stringToSetup(char * _s)
  104.  
  105. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  106. //
  107. // Paramaters
  108. //
  109. //    A serial port setup string in the form:
  110. //
  111. //       <baud_rate>,<data_bits>,<parity>,<stop_bits>
  112. //
  113. //    eg.:
  114. //
  115. //       "19200,8,N,1"
  116. //
  117. // Return Value
  118. //
  119. //    A bimasked value that can be bassed to a port setup routine.
  120. //    This is in the same basic format as a DOS INT 14h baudrate
  121. //    paramater.
  122. //
  123. // Functional Description
  124. //
  125. //    Parses the given string into a bitmask value.
  126. //
  127. // Remarks
  128. //
  129. //    The paramater string is NOT case sensitive.
  130. //    NO ERROR CHECKING!
  131. //
  132. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  133. {
  134.    char * p = _s;
  135.    unsigned long int _baud = atol(p);
  136.    p = strchr(p,',') + 1;
  137.    char _data = atoi(p);
  138.    p = strchr(p,',') + 1;
  139.    char _pari = *p;
  140.    p = strchr(p,',') + 1;
  141.    char _stop = atoi(p);
  142.    return (valuesToSetup(_baud,_data,_pari,_stop));
  143. };
  144. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  145.  
  146. // Member Function //
  147.  
  148. unsigned int FosIo::valuesToSetup(unsigned long int _baudrate,
  149.                                 unsigned char _databits,
  150.                                 unsigned char _parity,
  151.                                 unsigned char _stopbits)
  152.  
  153. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  154. //
  155. // Paramaters
  156. //
  157. //    Serial port settings for baud, data-bits (word length), parity
  158. //    and stop-bits.
  159. //    Parity is passed as an ASCII character like: 'E' == even parity.
  160. //
  161. // Return Value
  162. //
  163. //    A bimasked value that can be bassed to a port setup routine.
  164. //    This is in the same basic format as a DOS INT 14h baudrate
  165. //    paramater.
  166. //
  167. // Functional Description
  168. //
  169. //    Converts the supplied paramaters to a bitmask.
  170. //
  171. // Remarks
  172. //
  173. //    The paramater string is NOT case sensitive.
  174. //    NO ERROR CHECKING!
  175. //
  176. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  177. {
  178.    unsigned int _pmask = 0U;
  179.    _pmask |= ((_baudrate == 300L   ) ? b300  :
  180.              ((_baudrate == 600L   ) ? b600  :
  181.              ((_baudrate == 1200L  ) ? b1200 :
  182.              ((_baudrate == 2400L  ) ? b2400 :
  183.              ((_baudrate == 4800L  ) ? b4800 :
  184.              ((_baudrate == 9600L  ) ? b9600 :
  185.              ((_baudrate == 19200L ) ? b19k  :
  186.              ((_baudrate == 38400L ) ? b38k  :
  187.              ((_baudrate == 57600L ) ? b57k  :
  188.              ((_baudrate == 115200L) ? b115k : 0))))))))));
  189.  
  190.    switch (_databits)
  191.    {
  192.       case 6  :
  193.          _pmask |= six  ;
  194.          break;
  195.       case 7  :
  196.          _pmask |= seven;
  197.          break;
  198.       case 8  :
  199.          _pmask |= eight;
  200.          break;
  201.       default :
  202.          break;
  203.    }
  204.    switch (_parity)
  205.    {
  206.       case 'n':
  207.       case 'N':
  208.          _pmask |= none ;
  209.          break;
  210.       case 'e':
  211.       case 'E':
  212.          _pmask |= even ;
  213.          break;
  214.       case 'o':
  215.       case 'O':
  216.          _pmask |= odd  ;
  217.          break;
  218.       case 'm':
  219.       case 'M':
  220.          _pmask |= mark ;
  221.          break;
  222.       case 's':
  223.       case 'S':
  224.          _pmask |= space;
  225.          break;
  226.       default :
  227.          break;
  228.    }
  229.  
  230.    switch (_stopbits)
  231.    {
  232.       case 1 :
  233.          _pmask |= one  ;
  234.          break;
  235.       case 2 :
  236.          _pmask |= two  ;
  237.          break;
  238.       default:
  239.          break;
  240.    }
  241.  
  242.    return (_pmask);
  243. }
  244. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  245.  
  246. // Member Function //
  247.  
  248. char *  FosIo::setupToString(unsigned int _setup, char * _s)
  249.  
  250. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  251. //
  252. // Paramaters
  253. //
  254. //    A modem setting bitmask value, and optionally, a string to be
  255. //    filled with the converted mask.
  256. //
  257. // Return Value
  258. //
  259. //    A pointer to a string containing the converted mask.
  260. //
  261. // Functional Description
  262. //
  263. //    Takes a bitmask value and returns the settings in string form as:
  264. //
  265. //       <baud_rate>,<data_bits>,<parity>,<stop_bits>
  266. //
  267. //    eg.:
  268. //
  269. //       "19200,8,N,1"
  270. //
  271. //    The return value points to a static string that is overwritten with
  272. //    each call to ANY INSTANCE of the function. If a string is passed as
  273. //    a paramater, and is NOT NULL, it will be filled with a copy of the
  274. //    return value string. Max size, including the terminating NULL is 13.
  275. //
  276. // Remarks
  277. //
  278. //    NO ERROR CHECKING!
  279. //
  280. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  281. {
  282.    static char p[13];
  283.    unsigned long int _baudrate;
  284.    unsigned char     _databits,
  285.                      _stopbits;
  286.    unsigned char     _parity;
  287.    setupToValues(_setup,_baudrate,_databits,_parity,_stopbits);
  288.    sprintf(p,"%-lu,%u,%c,%u",_baudrate,_databits,_parity,_stopbits);
  289.    if (_s != NULL)
  290.       strcpy(_s,p);
  291.    return (p);
  292. }
  293. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  294.  
  295. // Member Function //
  296.  
  297. void FosIo::setupToValues(unsigned int _setup,
  298.                           unsigned long int & _baudrate,
  299.                           unsigned char & _databits,
  300.                           unsigned char & _parity,
  301.                           unsigned char & _stopbits)
  302.  
  303. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  304. //
  305. // Paramaters
  306. //
  307. //    A modem setup bitmask, and variable references for baud-rate,
  308. //    data-bits (word length), parity and stop-bits.
  309. //
  310. // Return Value
  311. //
  312. //    None
  313. //
  314. // Functional Description
  315. //
  316. //    Takes a bitmask and parses it into it's component parts.
  317. //
  318. // Remarks
  319. //
  320. //    Variables are passed BY REFERENCE ala Pascal VAR!
  321. //    The parity paramater returns an ASCII character like 'E' == even.
  322. //    NO ERROR CHECKING!
  323. //
  324. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  325. {
  326.    switch (_setup & bmask)
  327.    {
  328.       case b300 :
  329.          _baudrate = 300UL;
  330.          break;
  331.       case b600 :
  332.          _baudrate = 600UL;
  333.          break;
  334.       case b1200 :
  335.          _baudrate = 1200UL;
  336.          break;
  337.       case b2400 :
  338.          _baudrate = 2400UL;
  339.          break;
  340.       case b4800 :
  341.          _baudrate = 4800UL;
  342.          break;
  343.       case b9600 :
  344.          _baudrate = 9600UL;
  345.          break;
  346.       case b19k  :
  347.          _baudrate = 19200UL;
  348.          break;
  349.       case b38k  :
  350.          _baudrate = 38400UL;
  351.          break;
  352.       case b57k  :
  353.          _baudrate = 57600UL;
  354.          break;
  355.       case b115k  :
  356.          _baudrate = 115200UL;
  357.          break;
  358.       default:
  359.          _baudrate = 0UL;
  360.          break;
  361.    }
  362.  
  363.    switch (_setup & pmask)
  364.    {
  365.       case even   :
  366.          _parity = 'E';
  367.          break;
  368.       case odd    :
  369.          _parity = 'O';
  370.          break;
  371.       case mark   :
  372.          _parity = 'M';
  373.          break;
  374.       case none   :
  375.       default:
  376.          _parity = 'N';
  377.          break;
  378.    }
  379.  
  380.    switch (_setup & dmask)
  381.    {
  382.       case six    :
  383.          _databits = 6;
  384.          break;
  385.       case seven  :
  386.          _databits = 7;
  387.          break;
  388.       case eight  :
  389.       default:
  390.          _databits = 8;
  391.          break;
  392.    }
  393.  
  394.    switch (_setup & smask)
  395.    {
  396.       case two    :
  397.          _stopbits = 2;
  398.          break;
  399.       case one    :
  400.       default:
  401.          _stopbits = 1;
  402.          break;
  403.    }
  404. }
  405. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  406.  
  407. // Constructor //
  408.  
  409. Fossil::Fossil() : FosIo()
  410.  
  411. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  412. //
  413. // Paramaters
  414. //
  415. //    None.
  416. //
  417. // Return Value
  418. //
  419. //    None.
  420. //
  421. // Functional Description
  422. //
  423. //    Default constructor
  424. //
  425. // Remarks
  426. //
  427. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  428. {
  429.    initialised = 0;
  430. }
  431.  
  432. // Constructor //
  433.  
  434. Fossil::Fossil(unsigned int _port, unsigned int _cbrk) : FosIo()
  435.  
  436. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  437. //
  438. // Paramaters
  439. //
  440. //    Commport number (1 based) and optionally a boolean toggle
  441. //    for control-break counting.
  442. //
  443. // Return Value
  444. //
  445. //    True if successful.
  446. //
  447. // Functional Description
  448. //
  449. //    Initialises FOSSIL and gets information about same.
  450. //
  451. // Remarks
  452. //
  453. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  454. {
  455.    open(_port,_cbrk);
  456. }
  457.  
  458. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  459.  
  460. // Constructor //
  461.  
  462. Fossil::Fossil(unsigned int _port, unsigned char _mask, unsigned int _cbrk) :
  463.                FosIo()
  464.  
  465. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  466. //
  467. // Paramaters
  468. //
  469. //    As default, but adds a port setup bitmask.
  470. //
  471. // Return Value
  472. //
  473. //    As default.
  474. //
  475. // Functional Description
  476. //
  477. //    As default constructor, but also initialises the serial port.
  478. //
  479. // Remarks
  480. //
  481. //    See default constructor.
  482. //
  483. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  484. {
  485.    open(_port,_mask,_cbrk);
  486. }
  487. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  488.  
  489. // Constructor //
  490.  
  491. Fossil::Fossil(unsigned int _port, char * _initstr,
  492.                unsigned int _cbrk) : FosIo()
  493.  
  494. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  495. //
  496. // Paramaters
  497. //
  498. //    As default, but adds a port setup configuration string.
  499. //
  500. // Return Value
  501. //
  502. //    As default.
  503. //
  504. // Functional Description
  505. //
  506. //    As default constructor, but also initialises the serial port.
  507. //
  508. // Remarks
  509. //
  510. //    See default constructor.
  511. //
  512. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  513. {
  514.    open(_port,_initstr,_cbrk);
  515. }
  516. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  517.  
  518. // Constructor //
  519.  
  520. Fossil::Fossil(unsigned int _port, unsigned long int _baud,
  521.                unsigned char _data, unsigned char _pari,
  522.                unsigned char _stop, unsigned int _cbrk) : FosIo()
  523.  
  524. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  525. //
  526. // Paramaters
  527. //
  528. //    As default, but adds a port setup values.
  529. //
  530. // Return Value
  531. //
  532. //    As default.
  533. //
  534. // Functional Description
  535. //
  536. //    As default constructor, but also initialises the serial port.
  537. //
  538. // Remarks
  539. //
  540. //    See default constructor.
  541. //
  542. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  543. {
  544.    open(_port,_baud,_data,_pari,_stop,_cbrk);
  545. }
  546. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  547.  
  548. // Destructor //
  549.  
  550. Fossil::~Fossil()
  551.  
  552. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  553. //
  554. // Paramaters
  555. //
  556. //    None.
  557. //
  558. // Return Value
  559. //
  560. //    None.
  561. //
  562. // Functional Description
  563. //
  564. //    Class destructor. Calls close() to de-initialise the FOSSIL.
  565. //
  566. // Remarks
  567. //
  568. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  569. {
  570.    close();
  571. }
  572. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  573.  
  574. // Member Function //
  575.  
  576. unsigned int Fossil::open(unsigned int _port, unsigned char _mask,
  577.                           unsigned int _cbrk)
  578.  
  579. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  580. //
  581. // Paramaters
  582. //
  583. //    See equivalent constructor.
  584. //
  585. // Return Value
  586. //
  587. //    Ditto.
  588. //
  589. // Functional Description
  590. //
  591. //    Ditto.
  592. //
  593. // Remarks
  594. //
  595. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  596. {
  597.    commport = _port - 1;
  598.    if (_initialise(((_cbrk) ? &ctlcnt : NULL)))
  599.       set(_mask);
  600.    return (initialised);
  601. }
  602. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  603.  
  604. // Member Function //
  605.  
  606. unsigned int Fossil::open(unsigned int _port, char * _initstr,
  607.                           unsigned int _cbrk)
  608.  
  609. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  610. //
  611. // Paramaters
  612. //
  613. //    See equivalent constructor.
  614. //
  615. // Return Value
  616. //
  617. //    Ditto.
  618. //
  619. // Functional Description
  620. //
  621. //    Ditto.
  622. //
  623. // Remarks
  624. //
  625. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  626. {
  627.    return (open(_port,stringToSetup(_initstr),_cbrk));
  628. }
  629. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  630.  
  631. // Member Function //
  632.  
  633. unsigned int Fossil::open(unsigned int _port, unsigned long int _baud,
  634.                           unsigned char _data, unsigned char _pari,
  635.                           unsigned char _stop, unsigned int _cbrk)
  636.  
  637. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  638. //
  639. // Paramaters
  640. //
  641. //    See equivalent constructor.
  642. //
  643. // Return Value
  644. //
  645. //    Ditto.
  646. //
  647. // Functional Description
  648. //
  649. //    Ditto.
  650. //
  651. // Remarks
  652. //
  653. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  654. {
  655.    return (open(_port,valuesToSetup(_baud,_data,_pari,_stop),_cbrk));
  656. }
  657. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  658.  
  659.  
  660. // Member Function //
  661.  
  662. void Fossil::close()
  663.  
  664. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  665. //
  666. // Paramaters
  667. //
  668. //    None.
  669. //
  670. // Return Value
  671. //
  672. //    None.
  673. //
  674. // Functional Description
  675. //
  676. //    Call _deInitialise to shut down the FOSSIL.
  677. //
  678. // Remarks
  679. //
  680. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  681. {
  682.    _deInitialise();
  683. }
  684. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  685.  
  686. // Member Function //
  687.  
  688. unsigned int Fossil::set(unsigned char _mask)
  689.  
  690. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  691. //
  692. // Paramaters
  693. //
  694. //    A serial commport configuration bitmask ala PC/MS-DOS with minor
  695. //    exceptions for higher baudrates. See the FOSSIL-5 spec and
  696. //    the accompanying header file for details.
  697. //
  698. // Return Value
  699. //
  700. //    Serial commport status bitmask.
  701. //
  702. // Functional Description
  703. //
  704. //    Set comm commport baud, parity, data and stopbits.
  705. //
  706. // Remarks
  707. //
  708. //    NO ERROR CHECKING!
  709. //
  710. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  711. {
  712.    portmask = _mask;
  713.    _DX = commport;
  714.    _AL = _mask;
  715.    _AH = 0x00;
  716.    geninterrupt(0x14);
  717.    return (_AX);
  718. }
  719. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  720.  
  721. // Member Function //
  722.  
  723. unsigned int Fossil::putW(unsigned char _c)
  724.  
  725. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  726. //
  727. // Paramaters
  728. //
  729. //    A character or byte to be transmitted.
  730. //
  731. // Return Value
  732. //
  733. //    A serial commport status bitmask.
  734. //
  735. // Functional Description
  736. //
  737. //    Transmit a character with wait for buffer.
  738. //
  739. // Remarks
  740. //
  741. //    NO ERROR CHECKING!
  742. //    WAITS FOR ROOM IN THE BUFFER - conceivably FOREVER!
  743. //
  744. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  745. {
  746.    _DX = commport;
  747.    _AL = _c;
  748.    _AH = 0x01;
  749.    geninterrupt(0x14);
  750.    return (_AX);
  751. }
  752. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  753.  
  754. // Member Function //
  755.  
  756. unsigned char Fossil::getW()
  757.  
  758. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  759. //
  760. // Paramaters
  761. //
  762. //    None.
  763. //
  764. // Return Value
  765. //
  766. //    Character (byte) from FOSSIL input buffer.
  767. //
  768. // Functional Description
  769. //
  770. //    Gets a character from the input buffer - waits for one to
  771. //    become available if neccessary.
  772. //
  773. // Remarks
  774. //
  775. //    NO ERROR CHECKING!
  776. //    Waits for a character, possibly FOREVER!
  777. //
  778. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  779. {
  780.    _DX = commport;
  781.    _AH = 0x02;
  782.    geninterrupt(0x14);
  783.    return (_AL);
  784. }
  785. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  786.  
  787. // Member Function //
  788.  
  789. unsigned int Fossil::status()
  790.  
  791. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  792. //
  793. // Paramaters
  794. //
  795. //    None.
  796. //
  797. // Return Value
  798. //
  799. //    Serial commport status bitmask.
  800. //
  801. // Functional Description
  802. //
  803. //    Gets the serial commport status.
  804. //
  805. // Remarks
  806. //
  807. //    NO ERROR CHECKING!
  808. //
  809. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  810. {
  811.    _DX = commport;
  812.    _AH = 0x03;
  813.    geninterrupt(0x14);
  814.    return (_AX);
  815. }
  816. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  817.  
  818. // Member Function //
  819.  
  820. unsigned int Fossil::_initialise(unsigned char far * _countc)
  821.  
  822. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  823. //
  824. // Paramaters
  825. //
  826. //    An optional pointer to a ^C-press counter byte.
  827. //
  828. // Return Value
  829. //
  830. //    True (non-zero) on success.
  831. //
  832. // Functional Description
  833. //
  834. //    Initialises the FOSSIL driver. If "_countc" is supplied and
  835. //    is NOT NULL, then the byte it points to will be incremented
  836. //    each time a control-c is pressed at the keyboard - this is
  837. //    not normally needed.
  838. //
  839. // Remarks
  840. //
  841. //    NO ERROR CHECKING!
  842. //
  843. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  844. {
  845.    _ES = FP_SEG(&ctlcnt);
  846.    _CX = FP_OFF(&ctlcnt);
  847.    if (_countc != NULL)
  848.       _BX = 0x4F50 ;
  849.    else
  850.       _BX = 0x00;
  851.    _DX = commport;
  852.    _AH = 0x04;
  853.    geninterrupt(0x14);
  854.    maxfunc = _BL;
  855.    revision = _BH;
  856. #pragma warn -pia
  857.    if (initialised = (_AX == 0x1954) ? 1 : 0)
  858. #pragma warn .pia
  859.    {
  860.       _getTicks(*this);
  861.       _info(*this);
  862.       return (1);
  863.    }
  864.    return (0);
  865. }
  866. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  867.  
  868. // Member Function //
  869.  
  870. void Fossil::_deInitialise()
  871.  
  872. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  873. //
  874. // Paramaters
  875. //
  876. //    None.
  877. //
  878. // Return Value
  879. //
  880. //    None.
  881. //
  882. // Functional Description
  883. //
  884. //    De-initialises the FOSSIL driver.
  885. //
  886. // Remarks
  887. //
  888. // NO ERROR CHECKING!
  889. //
  890. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  891. {
  892.    _DX = commport;
  893.    _AH = 0x05;
  894.    geninterrupt(0x14);
  895. }
  896. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  897.  
  898. // Member Function //
  899.  
  900. unsigned char Fossil::dtr(unsigned int _raise)
  901.  
  902. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  903. //
  904. // Paramaters
  905. //
  906. //    Boolean "_raise"
  907. //
  908. // Return Value
  909. //
  910. //    True if DTR high.
  911. //
  912. // Functional Description
  913. //
  914. //    Sets the ports Data Terminal Ready (DTR) line. Raises signal
  915. //    if "_raise" is true.
  916. //
  917. // Remarks
  918. //
  919. //    NO ERROR CHECKING!
  920. //
  921. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  922. {
  923.    _DX = commport;
  924.    _AL = (_raise) ? 1 : 0;
  925.    _AH = 0x06;
  926.    geninterrupt(0x14);
  927.    return (_AL);
  928. }
  929. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  930.  
  931. // Member Function //
  932.  
  933. void Fossil::_getTicks(TimInfo & T)
  934.  
  935. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  936. //
  937. // Paramaters
  938. //
  939. //    TimInfo structure.
  940. //
  941. // Return Value
  942. //
  943. //    None.
  944. //
  945. // Functional Description
  946. //
  947. //    Fills TimInfo structure with system timer information. Since
  948. //    TimInfo is a parent class of Fossil, this routine is called
  949. //    internally on initialisation as: getTicks(*this) to fill
  950. //    in the data fields.
  951. //
  952. // Remarks
  953. //
  954. //    NO ERROR CHECKING!
  955. //
  956. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  957. {
  958.    _AH = 0x07;
  959.    geninterrupt(0x14);
  960.    T.intnum = _AL;
  961.    T.ticpersec = _AH;
  962.    T.mspertic = _DX;
  963. }
  964. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  965.  
  966. // Member Function //
  967.  
  968. void Fossil::flushOut()
  969.  
  970. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  971. //
  972. // Paramaters
  973. //
  974. //    None.
  975. //
  976. // Return Value
  977. //
  978. //    None.
  979. //
  980. // Functional Description
  981. //
  982. //    Flushes the output buffer.
  983. //
  984. // Remarks
  985. //
  986. //    NO ERROR CHECKING!
  987. //    Doesn't return until the output buffer is empty!
  988. //
  989. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  990. {
  991.    _DX = commport;
  992.    _AH = 0x08;
  993.    geninterrupt(0x14);
  994. }
  995. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  996.  
  997. // Member Function //
  998.  
  999. void Fossil::purgeOut()
  1000.  
  1001. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1002. //
  1003. // Paramaters
  1004. //
  1005. //    None.
  1006. //
  1007. // Return Value
  1008. //
  1009. //    None.
  1010. //
  1011. // Functional Description
  1012. //
  1013. //    Purges the output buffer.
  1014. //
  1015. // Remarks
  1016. //
  1017. //    NO ERROR CHECKING!
  1018. //    Destroys anything left in the buffer!
  1019. //
  1020. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1021. {
  1022.    _DX = commport;
  1023.    _AH = 0x09;
  1024.    geninterrupt(0x14);
  1025. }
  1026. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1027.  
  1028. // Member Function //
  1029.  
  1030. void Fossil::purgeIn()
  1031.  
  1032. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1033. //
  1034. // Paramaters
  1035. //
  1036. //    None.
  1037. //
  1038. // Return Value
  1039. //
  1040. //    None.
  1041. //
  1042. // Functional Description
  1043. //
  1044. //    Purges the input buffer.
  1045. //
  1046. // Remarks
  1047. //
  1048. //    NO ERROR CHECKING!
  1049. //    Destroys anything left in the buffer!
  1050. //    Will clear XOFF and/or raise RTS
  1051. //
  1052. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1053. {
  1054.    _DX = commport;
  1055.    _AH = 0x0A;
  1056.    geninterrupt(0x14);
  1057. }
  1058. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1059.  
  1060. // Member Function //
  1061.  
  1062. unsigned int Fossil::put(unsigned char _c)
  1063.  
  1064. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1065. //
  1066. // Paramaters
  1067. //
  1068. //    A character or byte to be sent.
  1069. //
  1070. // Return Value
  1071. //
  1072. //    True if character was "sent."
  1073. //
  1074. // Functional Description
  1075. //
  1076. //    Outputs a character to the output buffer, if room is available.
  1077. //    Does NOT wait for the buffer... if there isn't room, the call fails.
  1078. //
  1079. // Remarks
  1080. //
  1081. //    NO ERROR CHECKING!
  1082. //
  1083. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1084. {
  1085.    _DX = commport;
  1086.    _AL = _c;
  1087.    _AH = 0x0B;
  1088.    geninterrupt(0x14);
  1089.    return (_AX);
  1090. }
  1091. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1092.  
  1093. // Member Function //
  1094.  
  1095. unsigned int Fossil::peek()
  1096.  
  1097. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1098. //
  1099. // Paramaters
  1100. //
  1101. //    None.
  1102. //
  1103. // Return Value
  1104. //
  1105. //    Low byte == next character in buffer if one is available, else
  1106. //    returns 0FFFFh.
  1107. //
  1108. // Functional Description
  1109. //
  1110. //    Non destructive "look ahead" into the comm input buffer.
  1111. //
  1112. // Remarks
  1113. //
  1114. //    NO ERROR CHECKING!
  1115. //    Does NOT remove any pending characters from the buffer.
  1116. //
  1117. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1118. {
  1119.    _DX = commport;
  1120.    _AH = 0x0C;
  1121.    geninterrupt(0x14);
  1122.    return (_AX);
  1123. }
  1124. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1125.  
  1126. // Member Function //
  1127.  
  1128. unsigned int Fossil::peekKey()
  1129.  
  1130. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1131. //
  1132. // Paramaters
  1133. //
  1134. //    None.
  1135. //
  1136. // Return Value
  1137. //
  1138. //    Low byte == next character in buffer if one is available, else
  1139. //    returns 0FFFFh. High byte == scancode if extended character.
  1140. //
  1141. // Functional Description
  1142. //
  1143. //    Non destructive "look ahead" into the keyboard buffer.
  1144. //
  1145. // Remarks
  1146. //
  1147. //    NO ERROR CHECKING!
  1148. //    Does NOT remove any pending characters from the buffer.
  1149. //
  1150. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1151. {
  1152.    _AH = 0x0D;
  1153.    geninterrupt(0x14);
  1154.    return (_AX);
  1155. }
  1156. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1157.  
  1158. // Member Function //
  1159.  
  1160. unsigned int Fossil::getKey()
  1161.  
  1162. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1163. //
  1164. // Paramaters
  1165. //
  1166. //    None.
  1167. //
  1168. // Return Value
  1169. //
  1170. //    Low byte = next character from keyboard. High byte contains
  1171. //    scancodes for extended characters.
  1172. //
  1173. // Functional Description
  1174. //
  1175. //    Gets the next character from the keyboard - waits until one
  1176. //    becomes available.
  1177. //
  1178. // Remarks
  1179. //
  1180. //    NO ERROR CHECKING!
  1181. //
  1182. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1183. {
  1184.    _AH = 0x0E;
  1185.    geninterrupt(0x14);
  1186.    return (_AX);
  1187. }
  1188. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1189.  
  1190. // Member Function //
  1191.  
  1192. void Fossil::flow(unsigned char _mask)
  1193.  
  1194. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1195. //
  1196. // Paramaters
  1197. //
  1198. //    Flow control bitmask.
  1199. //
  1200. // Return Value
  1201. //
  1202. //    None.
  1203. //
  1204. // Functional Description
  1205. //
  1206. //    Enables/disables various flow control settings. See FOSSIL spec. or
  1207. //    header file for more information.
  1208. //
  1209. // Remarks
  1210. //
  1211. //    NO ERROR CHECKING!
  1212. //
  1213. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1214. {
  1215.    _DX = commport;
  1216.    _AL = _mask;
  1217.    _AH = 0x0F;
  1218.    geninterrupt(0x14);
  1219. }
  1220. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1221.  
  1222. // Member Function //
  1223.  
  1224. unsigned int Fossil::control(unsigned char _mask)
  1225.  
  1226. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1227. //
  1228. // Paramaters
  1229. //
  1230. //    Bitmask indicating check on/off and possibly force release
  1231. //    of controls. See FOSSIL spec or header file for more
  1232. //    information.
  1233. //
  1234. // Return Value
  1235. //
  1236. //    True if ^C or ^K has been detected since the last call to this
  1237. //    function.
  1238. //
  1239. // Functional Description
  1240. //
  1241. //    Turns on/off ^C/^K checking, returns status of same if enabled,
  1242. //    and also can force a transmitter stop/release (good for keeping
  1243. //    spurious control characters from hanging the system).
  1244. //
  1245. // Remarks
  1246. //
  1247. //    NO ERROR CHECKING!
  1248. //
  1249. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1250. {
  1251.    _DX = commport;
  1252.    _AL = _mask;
  1253.    _AH = 0x10;
  1254.    geninterrupt(0x14);
  1255.    return (_AX);
  1256. }
  1257. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1258.  
  1259. // Member Function //
  1260.  
  1261. void Fossil::gotoXY(unsigned char _row, unsigned char _col)
  1262.  
  1263. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1264. //
  1265. // Paramaters
  1266. //
  1267. //    Screen row and column to position the on.
  1268. //
  1269. // Return Value
  1270. //
  1271. //    None.
  1272. //
  1273. // Functional Description
  1274. //
  1275. //    Position the cursor on the screen.
  1276. //
  1277. // Remarks
  1278. //
  1279. //    NO ERROR CHECKING!
  1280. //    Row/col are zero (0) based!
  1281. //
  1282. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1283. {
  1284.    _DH = _row;
  1285.    _DL = _col;
  1286.    _AH = 0x11;
  1287.    geninterrupt(0x14);
  1288. }
  1289. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1290.  
  1291. // Member Function //
  1292.  
  1293. void Fossil::whereXY(unsigned char & _row, unsigned char & _col)
  1294.  
  1295. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1296. //
  1297. // Paramaters
  1298. //
  1299. //    Variables to fill with cursor row and column positions.
  1300. //
  1301. // Return Value
  1302. //
  1303. //    None.
  1304. //
  1305. // Functional Description
  1306. //
  1307. //    Get the cursor position.
  1308. //
  1309. // Remarks
  1310. //
  1311. //    NO ERROR CHECKING!
  1312. //    Row/col are zero (0) based!
  1313. //    Variables are passed BY REFERENCE! Don't do a 'C' style
  1314. //    whereXY(&row,&col) unless you like bogus screen positions!
  1315. //
  1316. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1317. {
  1318.    _AH = 0x12;
  1319.    geninterrupt(0x14);
  1320.    _row = _DH;
  1321.    _col = _DL;
  1322. }
  1323. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1324.  
  1325. // Member Function //
  1326.  
  1327. void Fossil::putANSI(unsigned char _c)
  1328.  
  1329. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1330. //
  1331. // Paramaters
  1332. //
  1333. //    Character to output to screen.
  1334. //
  1335. // Return Value
  1336. //
  1337. //    None.
  1338. //
  1339. // Functional Description
  1340. //
  1341. //    Output a character to the screen via ANSI.SYS
  1342. //
  1343. // Remarks
  1344. //
  1345. //    NO ERROR CHECKING!
  1346. //
  1347. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1348. {
  1349.    _AL = _c;
  1350.    _AH = 0x13;
  1351.    geninterrupt(0x14);
  1352. }
  1353. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1354.  
  1355. // Member Function //
  1356.  
  1357. void Fossil::watchdog(unsigned int _enable)
  1358.  
  1359. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1360. //
  1361. // Paramaters
  1362. //
  1363. //    Boolean: True == enable watchdog.
  1364. //
  1365. // Return Value
  1366. //
  1367. //    None.
  1368. //
  1369. // Functional Description
  1370. //
  1371. //    Enables or disables FOSSIL carrier watchdog.
  1372. //
  1373. // Remarks
  1374. //
  1375. //    NO ERROR CHECKING!
  1376. //    Not changed by init/de-init code... be careful if you exit
  1377. //    your program and have left this enabled: You may get reboots
  1378. //    where you didn't want or expect them.
  1379. //
  1380. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1381. {
  1382.    _DX = commport;
  1383.    _AL = (_enable) ? 1 : 0;
  1384.    _AH = 0x14;
  1385.    geninterrupt(0x14);
  1386. }
  1387. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1388.  
  1389. // Member Function //
  1390.  
  1391. void Fossil::putBIOS(unsigned char _c)
  1392.  
  1393. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1394. //
  1395. // Paramaters
  1396. //
  1397. //    Character to output to screen.
  1398. //
  1399. // Return Value
  1400. //
  1401. //    None.
  1402. //
  1403. // Functional Description
  1404. //
  1405. //    Output a character to the screen via BIOS.
  1406. //
  1407. // Remarks
  1408. //
  1409. //    NO ERROR CHECKING!
  1410. //    Reentrancy is allegedly o.k. via this routine, but who
  1411. //    really knows? ;-)
  1412. //
  1413. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1414. {
  1415.    _AL = _c;
  1416.    _AH = 0x15;
  1417.    geninterrupt(0x14);
  1418. }
  1419. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1420.  
  1421. // Member Function //
  1422.  
  1423. unsigned int Fossil::timerChain(unsigned int _insert, void (far * _f)())
  1424.  
  1425. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1426. //
  1427. // Paramaters
  1428. //
  1429. //    Boolean switch for add/remove, and the function pointer
  1430. //    to be added/removed.
  1431. //
  1432. // Return Value
  1433. //
  1434. //    True if successful.
  1435. //
  1436. // Functional Description
  1437. //
  1438. //    Inserts or deletes a user-specified function into/from the
  1439. //    timer-tick interrupt chain.
  1440. //
  1441. // Remarks
  1442. //
  1443. //    NO ERROR CHECKING!
  1444. //
  1445. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1446. {
  1447.    _ES = FP_SEG(_f);
  1448.    _DX = FP_OFF(_f);
  1449.    _AL = (_insert) ? 1 : 0;
  1450.    _AH = 0x16;
  1451.    geninterrupt(0x14);
  1452.    return ((_AX) ? 1 : 0);
  1453. }
  1454. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1455.  
  1456. // Member Function //
  1457.  
  1458. void Fossil::reboot(unsigned int _warm)
  1459.  
  1460. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1461. //
  1462. // Paramaters
  1463. //
  1464. //    Boolean switch for warm/cold.
  1465. //
  1466. // Return Value
  1467. //
  1468. //    None I should hope! ;-)
  1469. //
  1470. // Functional Description
  1471. //
  1472. //    Force a system reboot, either warm or cold.
  1473. //
  1474. // Remarks
  1475. //
  1476. //    If you don't understand this one, you shouldn't be reading
  1477. //    this at all! ;-)
  1478. //
  1479. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1480. {
  1481.    _AL = (_warm) ? 1 : 0;
  1482.    _AH = 0x17;
  1483.    geninterrupt(0x14);
  1484. }
  1485. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1486.  
  1487. // Member Function //
  1488.  
  1489. unsigned int Fossil::read(void far * _buffer, unsigned int _count)
  1490.  
  1491. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1492. //
  1493. // Paramaters
  1494. //
  1495. //    A pointer to the buffer to fill, and the number of bytes/chars to
  1496. //    read.
  1497. //
  1498. // Return Value
  1499. //
  1500. //    The actual number of characters read.
  1501. //
  1502. // Functional Description
  1503. //
  1504. //    Reads up to "_count" characters into "_buffer" from the
  1505. //    comm input buffer.
  1506. //
  1507. // Remarks
  1508. //
  1509. //    NO ERROR CHECKING!
  1510. //    Does not wait for characters! If less than "_count"
  1511. //    are available, it will only return that many.
  1512. //
  1513. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1514. {
  1515.    _ES = FP_SEG(_buffer);
  1516.    _DX = FP_OFF(_buffer);
  1517.    _CX = _count;
  1518.    _DX = commport;
  1519.    _AH = 0x18;
  1520.    geninterrupt(0x14);
  1521.    return (_AX);
  1522. }
  1523. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1524.  
  1525. // Member Function //
  1526.  
  1527. unsigned int Fossil::write(void far * _buffer, unsigned int _count)
  1528.  
  1529. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1530. //
  1531. // Paramaters
  1532. //
  1533. //    A pointer to the buffer to fill, and the number of bytes/chars to
  1534. //    write.
  1535. //
  1536. // Return Value
  1537. //
  1538. //    The actual number of characters sent.
  1539. //
  1540. // Functional Description
  1541. //
  1542. //    Writes up to "_count" characters from "_buffer" to the
  1543. //    comm output buffer.
  1544. //
  1545. // Remarks
  1546. //
  1547. //    NO ERROR CHECKING!
  1548. //    Does not wait for buffer space! If less than "_count"
  1549. //    are available, it will only output that many.
  1550. //
  1551. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1552. {
  1553.    _ES = FP_SEG(_buffer);
  1554.    _DX = FP_OFF(_buffer);
  1555.    _CX = _count;
  1556.    _DX = commport;
  1557.    _AH = 0x19;
  1558.    geninterrupt(0x14);
  1559.    return (_AX);
  1560. }
  1561. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1562.  
  1563. // Member Function //
  1564.  
  1565. void Fossil::brk(unsigned int _start)
  1566.  
  1567. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1568. //
  1569. // Paramaters
  1570. //
  1571. //    Boolean indicating start/stop.
  1572. //
  1573. // Return Value
  1574. //
  1575. //    None.
  1576. //
  1577. // Functional Description
  1578. //
  1579. //    Starts/stops sending a break signal.
  1580. //
  1581. // Remarks
  1582. //
  1583. //    NO ERROR CHECKING!
  1584. //    Flow control commands will stop a break!
  1585. //
  1586. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1587. {
  1588.    _DX = commport;
  1589.    _AL = (_start) ? 1 : 0;
  1590.    _AH = 0x1A;
  1591.    geninterrupt(0x14);
  1592. }
  1593. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1594.  
  1595. // Member Function //
  1596.  
  1597. unsigned int Fossil::_info(FosData & _D)
  1598.  
  1599. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1600. //
  1601. // Paramaters
  1602. //
  1603. //    A FosData structure.
  1604. //
  1605. // Return Value
  1606. //
  1607. //    The actual number of bytes transferred to the structure.
  1608. //
  1609. // Functional Description
  1610. //
  1611. //    Fills a FosInfo structure with the FOSSIL driver information.
  1612. //
  1613. // Remarks
  1614. //
  1615. //    NO ERROR CHECKING!
  1616. //    Intended for internal useto fill the base class FosData
  1617. //    variables: info(*this); This is automagically done on
  1618. //    initialization.
  1619. //
  1620. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1621. {
  1622.    _CX = sizeof(FosData);
  1623.    _ES = FP_SEG(&_D);
  1624.    _DI = FP_OFF(&_D);
  1625.    _DX = commport;
  1626.    _AH = 0x1B;
  1627.    geninterrupt(0x14);
  1628.    return (_AX);
  1629. }
  1630. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1631.  
  1632. // Member Function //
  1633.  
  1634. unsigned int Fossil::installApi(unsigned char _code, void (far * _f)())
  1635.  
  1636. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1637. //
  1638. // Paramaters
  1639. //
  1640. //    Subfunction number that will call this function,
  1641. //    and a pointer to the user function.
  1642. //
  1643. // Return Value
  1644. //
  1645. //    True if user function installed successfully.
  1646. //
  1647. // Functional Description
  1648. //
  1649. //    Install a user API.
  1650. //
  1651. // Remarks
  1652. //
  1653. //    The installed function is callable as a FOSSIL subfunction,
  1654. //    by specifying the subfunction number from "_code."
  1655. //    See FOSSIL spec for furthur information.
  1656. //
  1657. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1658. {
  1659.    _ES = FP_SEG(_f);
  1660.    _DX = FP_OFF(_f);
  1661.    _AL = _code;
  1662.    _AH = 0x7F;
  1663.    geninterrupt(0x14);
  1664.    return (((_AX == 0x1954) && (_BH)) ? 1 : 0);
  1665. }
  1666. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1667.  
  1668. // Member Function //
  1669.  
  1670. unsigned int Fossil::removeApi(unsigned char _code, void (far * _f)())
  1671.  
  1672. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1673. //
  1674. // Paramaters
  1675. //
  1676. //    Subfunction number for this function
  1677. //    and a pointer to the user function.
  1678. //
  1679. // Return Value
  1680. //
  1681. //    True if user function removed successfully.
  1682. //
  1683. // Functional Description
  1684. //
  1685. //    Remove a user API.
  1686. //
  1687. // Remarks
  1688. //
  1689. //    See installApi() above.
  1690. //
  1691. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1692. {
  1693.    _ES = FP_SEG(_f);
  1694.    _DX = FP_OFF(_f);
  1695.    _AL = _code;
  1696.    _AH = 0x7F;
  1697.    geninterrupt(0x14);
  1698.    return (((_AX == 0x1954) && (_BH)) ? 1 : 0);
  1699. }
  1700. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1701.  
  1702. // Operator //
  1703.  
  1704. unsigned int Fossil::operator ! ()
  1705.  
  1706. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1707. //
  1708. // Paramaters
  1709. //
  1710. //    None.
  1711. //
  1712. // Return Value
  1713. //
  1714. //    True if an error condition exists.
  1715. //
  1716. // Functional Description
  1717. //
  1718. // Remarks
  1719. //
  1720. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1721. {
  1722.    return ((!initialised) ? 1 : 0);
  1723. }
  1724. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1725.  
  1726. // Member Function //
  1727.  
  1728. unsigned int Fossil::carrier()
  1729.  
  1730. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1731. //
  1732. // Paramaters
  1733. //
  1734. //    None.
  1735. //
  1736. // Return Value
  1737. //
  1738. //    True if data carrier detect line is high.
  1739. //
  1740. // Functional Description
  1741. //
  1742. // Remarks
  1743. //
  1744. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1745. {
  1746.    return ((status() & FosIo::dcd) ? 1 : 0);
  1747. }
  1748. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1749.  
  1750. // Member Function //
  1751.  
  1752. unsigned int Fossil::incoming()
  1753.  
  1754. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1755. //
  1756. // Paramaters
  1757. //
  1758. //    None.
  1759. //
  1760. // Return Value
  1761. //
  1762. //    True if there is data in the receive buffer.
  1763. //
  1764. // Functional Description
  1765. //
  1766. // Remarks
  1767. //
  1768. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1769. {
  1770.    return ((status() & FosIo::rxr) ? 1 : 0);
  1771. }
  1772. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1773.  
  1774. // Member Function //
  1775.  
  1776. void Fossil::info()
  1777.  
  1778. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1779. //
  1780. // Paramaters
  1781. //
  1782. //    None.
  1783. //
  1784. // Return Value
  1785. //
  1786. //    None.
  1787. //
  1788. // Functional Description
  1789. //
  1790. //    Performs an update on the member data in struct FosData.
  1791. //
  1792. // Remarks
  1793. //
  1794. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1795. {
  1796.    _info(*this);
  1797. }
  1798. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1799.  
  1800. // Member Function //
  1801.  
  1802. unsigned int Fossil::mode()
  1803.  
  1804. // Summary =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1805. //
  1806. // Paramaters
  1807. //
  1808. //    None.
  1809. //
  1810. // Return Value
  1811. //
  1812. //    The current bitmask settings for the comm port in use.
  1813. //
  1814. // Functional Description
  1815. //
  1816. //    Just returns the mask.
  1817. //
  1818. // Remarks
  1819. //
  1820. //    Use the FosIo conversion functions to make this meaningful
  1821. //    to carbon based sentient beings.
  1822. //
  1823. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1824. {
  1825.    return (portmask);
  1826. }
  1827. // End =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1828.  
  1829.